extends Level
signal load_finished
var loadded:bool=false:
	set(v):
		loadded=v
		if loadded:
			Global.display_tip.emit("a d 左右移动，空格跳跃")
@onready var camera: Camera2D = %Camera
@onready var player: CharacterBody2D = %Player
@onready var eye_trans: Control = $Front/EyeTrans
var _should_start_from_begin:bool=true
func _ready() -> void:
	if find_child("Temp"):
		_should_start_from_begin=true
	else:_should_start_from_begin=false
func init_state()->void:
	$World.visible=false
	$World/Items.visible=false
	$Marks.visible=false
	$World/Effect.visible=false
	pass
func sample_load_in()->void:
	eye_trans.visible=true
	Black.visible=false
	eye_trans.eye(true)
	await eye_trans.eye_finish
	Global.display_str.emit("出发吧!")
	Global.player_movment_mode.emit("walk")
	$Env.visible=true
	loadded=true
func load_in()->void:
	if not _should_start_from_begin:
		sample_load_in()
		return
	init_state()
	if not is_node_ready():await ready
	await get_tree().create_timer(0.1).timeout
	camera.look_at_pos($Marks/CameraInitPos.position)
	camera.position=$Marks/CameraInitPos.position
	player.visible=false
	eye_trans.visible=true
	Black.visible=false
	eye_trans.eye(true)
	await eye_trans.eye_finish
	Global.display_str.emit("这是哪??")
	Global.display_str.emit("周围白茫茫一片，似乎什么都没有")
	await get_tree().create_timer(6.0).timeout
	load_map()
	Global.display_str.emit("那是...")
	Global.display_str.emit("桥?")
	await load_finished
	await Global.display_string_finished
	player.visible=true
	camera.follow_player()
	Global.display_str.emit("或许你需要朝某个方向前进")
	Global.player_movment_mode.emit("tie")
	$World.visible = true
	$Temp.queue_free()
	await Global.display_string_finished
	$World/Items.visible=true
	$Marks.visible=true
	$World/Effect.visible=true
	Global.player_movment_mode.emit("walk")
	$Env.visible=true
	loadded=true

var _load_in_twn:Tween
func load_map()->void:
	var temp: Node2D = $Temp
	var hole = temp.get_node("BridgeHole") as Sprite2D
	var gnd = temp.get_node("BridgeGround") as Sprite2D
	if not _load_in_twn and hole and gnd:
		print("map1 loadin")
		$World.visible = false
		hole.self_modulate = Color(1.0,1.0,1.0,0.0)
		hole.position.y = 50
		gnd.position.y = -185
		_load_in_twn = create_tween()
		_load_in_twn.tween_property(hole,"self_modulate",Color(1.0, 1.0, 1.0, 1.0),0.5)
		_load_in_twn.parallel().tween_property(hole,"position",Vector2(0.0,-50.0),3)
		_load_in_twn.tween_property(gnd.material,"shader_parameter/persent",1.0,1.0)
		_load_in_twn.tween_callback(print.bind("map1 loadin finish"))
		await _load_in_twn.finished
		load_finished.emit()
func simple_load()->void:
	pass
func reset_to_none()->void:
	pass
